# 只读属性的设置
class Person():
    def __setattr__(self, key, value):
        if key == 'age' and key in self.__dict__.keys():
            print(f'属性{key}是只读的，无法设置')
        else:
            self.__dict__[key] = value

p1 = Person()
p1.age = 18
print(p1.age)

p1.age = 100



